<template>
  <div>
    <!-- 没有图片 -->
    <van-cell v-if="type === 0" :title="aritcleInfo.title" :label="label" />
    <!-- 一张图片 -->
    <van-cell v-else-if="type === 1" :title="aritcleInfo.title" :label="label">
      <van-image width="100" height="100" :src="aritcleInfo.cover?.images[0]"
    /></van-cell>
    <!-- 三张图片 -->
    <van-cell v-else :title="aritcleInfo.title">
      <template #label>
        <van-image
          width="100"
          height="100"
          v-for="(item, index) in aritcleInfo.cover?.images"
          :key="index"
          :src="item"
        />
        <span>{{ label }}</span>
      </template>
    </van-cell>
  </div>
</template>

<script>
import dayjs from '@/utils/dayjs'
export default {
  props: {
    // 默认值： 如果是基本数据类型直接给
    // 复杂数据类型，一函数的返回值给
    aritcleInfo: {
      type: Object,
      default: () => ({})
    }
  },
  computed: {
    type() {
      return this.aritcleInfo.cover?.type
    },
    label() {
      const { aut_name, comm_count, pubdate } = this.aritcleInfo
      return `${aut_name} ${comm_count}评论 ${dayjs(pubdate).fromNow()}`
    }
  }
}
</script>

<style></style>
